Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore: refactor split code for two phase split. #48244

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Nov 2, 2023

What problem does this PR solve?

Issue Number: ref #33937

Problem Summary:
split too many regions on the same node. will become bottleneck of a large scale cluster restoration.

What is changed and how it works?

  1. introduce 2-phase split during restore. when enable fine-grained restore. it will pick keys by store count, and doing a two-phase split scatter. which will save time from scatter-heavy workloads.
  2. refactor code and unified utils.retry for all related backoffer.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

without this change:
image

with this change:
image

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

restore: improve performance by reduce scatter operations.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Nov 2, 2023
Copy link

ti-chi-bot bot commented Nov 2, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 2, 2023
Copy link

tiprow bot commented Nov 2, 2023

Hi @3pointer. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@3pointer
Copy link
Contributor Author

3pointer commented Nov 3, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked labels Nov 3, 2023
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2023
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 1, 2023
@3pointer
Copy link
Contributor Author

3pointer commented Dec 1, 2023

/ok-to-test

@3pointer 3pointer marked this pull request as ready for review December 4, 2023 03:57
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 4, 2023
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Merging #48244 (9859de1) into master (1f49f2d) will decrease coverage by 3.2356%.
Report is 3 commits behind head on master.
The diff coverage is 0.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48244        +/-   ##
================================================
- Coverage   71.9200%   68.6844%   -3.2356%     
================================================
  Files          1438       1440         +2     
  Lines        345755     408072     +62317     
================================================
+ Hits         248667     280282     +31615     
- Misses        76821     108767     +31946     
+ Partials      20267      19023      -1244     
Flag Coverage Δ
integration 43.9460% <0.0000%> (?)
unit 71.9336% <ø> (+0.0136%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.3129% <ø> (ø)
parser ∅ <ø> (∅)
br 43.7210% <0.0000%> (-7.8741%) ⬇️

@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2023
@sre-bot
Copy link
Contributor

sre-bot commented Dec 18, 2023

CLA assistant check
All committers have signed the CLA.

br/pkg/restore/pipeline_items.go Show resolved Hide resolved
}

for _, dr := range res {
outCh <- dr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ctx to avoid getting stuck

@@ -942,11 +959,13 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
})
}

blockTableStream := GoBlockCreateTablesPipeline(ctx, maxRestoreBatchSizeLimit, tableStream)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block only if granularity == string(CoarseGrained)

br/pkg/task/restore.go Show resolved Hide resolved
})

for _, tbl := range cachedTables {
outCh <- tbl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ctx to avoid getting stuck

@@ -1490,7 +1490,7 @@ func createRestoreClient(ctx context.Context, g glue.Glue, cfg *RestoreConfig, m
client.SetCrypter(&cfg.CipherInfo)
client.SetConcurrency(uint(cfg.Concurrency))
client.SetSwitchModeInterval(cfg.SwitchModeInterval)
client.InitClients(u, false, false)
client.InitClients(ctx, u, false, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the log restore affected by the modified InitClient?

br/pkg/restore/client.go Outdated Show resolved Hide resolved
br/pkg/restore/client.go Outdated Show resolved Hide resolved
br/pkg/restore/import.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2024
Copy link

ti-chi-bot bot commented Jan 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BornChanger, Leavrth

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2024
Copy link

ti-chi-bot bot commented Jan 3, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-03 09:28:24.409406731 +0000 UTC m=+2249195.446633658: ☑️ agreed by Leavrth.
  • 2024-01-03 10:16:30.05398002 +0000 UTC m=+2252081.091206946: ☑️ agreed by BornChanger.

@BornChanger
Copy link
Contributor

/retest

@ti-chi-bot ti-chi-bot bot merged commit 44f33c6 into pingcap:master Jan 3, 2024
21 checks passed
AilinKid pushed a commit to AilinKid/tidb that referenced this pull request Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants